<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>

<html>

 <head>
    
    <title>BOM管理</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>

		<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/basic/materbom";
		var basic_WUrl="basic/materbom";
		var basic_Title="BOM";
		var show_Width=520;
		var show_Hight=300;
		function createSearch(){
			init(1,8,'80,100,80,100,80,100,80,100','25%');

			//第一行的数据
			addCommon(0,0,"lable","BOM名称：");
			addCommon(0,1,"txtlike","zd002Name");
			addCommon(0,2,"lable","BOM编码：");
			addCommon(0,3,"txtlike","zd001Code");
			addCommon(0,4,"lable","BOM规格：");
			addCommon(0,5,"txtlike","zd005Size");
			addCommon(0,6,"lable","BOM型号：");
			addCommon(0,7,"txtlike","zd004Model");
		}
		function searchAP(){	
			multipleSearch("#table1",true,"",basic_Url+"/list.do");
		}

		function gettreeData() 
		 {    
			var manager = null;
			manager = $("#tree1").ligerGetTreeManager(); 
			manager.clear();
	        manager.loadData(null, basic_Url+'/tree.do');
	        manager.collapseAll();
		 }
		
		jQuery(document).ready(function() {
			//创建JQGRID表格
			$("#table1").ligerGrid({
		        columns: [
		                      { display: 'BOM名称', name: 'zd002Name', width: 120 },
			                  { display: 'BOM编码', name: 'zd001Code', width: 120 },
			                  { display: '成品名称', name: 'zd003ParentId', width: 120,
			                	  render: function (item){
			                		  if(item.basicMaterialsDO==null){
			                			  return "";
			                		  }else{
			                			  return item.basicMaterialsDO.zd002Name;
			                		  }
			                	  }},
			                { display: '尺寸', name: 'zd005Size', width: 120},
			                { display: '型号', name: 'zd004Model', width: 120},
			                  { display: '创建人', name: 'bizCreatorName', width: 120},
			                  { display: '创建时间', name: 'bizCreatorDate', width: 120,
			                	  render: function (item){
			                		  var cdate=new Date(item.bizCreatorDate);
			                		  return formatDate(cdate,"yyyy-MM-dd HH:mm:ss");
			                	  }
			                  },
			                  { display: '备注', name: 'zd016Remark', width: 120 }
		                      ],  usePager: true,pageSize:15,pageSizeOptions :[15,25,35],
		                      url : basic_Url+"/list.do",enabledSort:false,
		                      width: "100%", height:"98%", checkbox: true,      
		                      onDblClickRow : function (data, rowindex, rowobj){
		                    	  edititem(data);
		                       },
		                      toolbar: { items: [
												  { text: '增加BOM', click: additem, icon: 'add' },
		                                          { text: '修改', click: getSelected, icon: 'modify' },
		                                          { line: true },
		                                          { text: '删除', click: del, img: '${ctx}/js/ligerUI/skins/icons/delete.gif' }
		                                          ]
		                                          }
		                  });
			$("#pageloading").hide();
			
			
			$("#layout1").ligerLayout({ leftWidth: 200,height: '100%',heightDiff:-24,space:4});
			var actionNodeID=null;
			 
			
			$("#tree1").ligerTree({  
				 url: basic_Url+'/tree.do',
				 nodeWidth: 115,
				 checkbox: false,
		         slide: false,
		         onClick:function(node){
		        	 actionNodeID = node.data.id;
		        	 multipleSearch("#table1",true,"",basic_Url+"/list.do?ID="+node.data.id);
		         }
		     });
			
			 
			 //添加物料
			 function additem(){
				 if(actionNodeID == null || actionNodeID.length<=0){
					$.dialog.alert("请选择成品Bom的类型!");
					return false;
				 }
				var url = "basic/materbom/operate/add/"+actionNodeID+".do";
				ShowIframeDialog("operate","添加成品Bom",url,320,300);
			 }
			 
			//修改物料
			 function edititem(data){
					var url = "basic/materbom/operate/edit/"+data.id+".do";
					ShowIframeDialog("operate","修改成品Bom",url,320,300);
			 }
			 
			//选择物料
			 function getSelected(){
				 var grid = $("#table1").ligerGetGridManager(); 
					var rows = grid.getCheckedRows();
					var data =grid.getSelectedRow();
					if(rows.length==0){
						$.dialog.alert("请选择一行数据!");
						return false;
					}else{
						edititem(data);
					}
			}
			 
		});
		document.onkeydown=keyListener;   
		function keyListener(e){   
		    e = e ? e : event;  
		    if(e.keyCode == 13){   
		    	searchAP();
		    }   
		} 
		function excelMateriaExport(dest){
			var filtersStr = generateCondition();
		   	var path = "${ctx}/excel/"+dest+".do?filters="+filtersStr+"&_search=true";
			window.open(path,"_blank");
		}
		
	</script>
  </head>
<body style="padding:10px" onload="createSearch()">  
       <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" onclick="excelMateriaExport('bomMaterialListExcel')">导出BOM物料</button></div></div></li>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" onclick="excelMateriaExport('bomProcessListExcel')">导出BOM工序</button></div></div></li>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      <div id="layout1">
            <div position="left" title="物料类型">
            <div style="width:100%; height:390px; float:left;overflow:scroll;">
   				 <ul id="tree1"></ul>
    		</div> 
            </div>
            <div position="center" title="物料类型列表" id="table1">
            
            </div>  
        </div> 
    </body>
</html>